package com.ctvit.cch.core.enums;

import lombok.Getter;

/**
 * 创作来源枚举
 *
 * @author heyingcheng
 * @date 2025/11/07
 */
@Getter
public enum CreationSourceEnum {

/**
     * 灵感
     */
    INSP("INSP", "灵感"),
    
    /**
     * 热门
     */
    HOT("HOT", "热门"),
    
    /**
     * 创意
     */
    IDEA("IDEA", "创意");
    
    private final String code;
    private final String comment;
    
    CreationSourceEnum(String code, String comment) {
        this.code = code;
        this.comment = comment;
    }
    
    public String getCode() {
        return code;
    }
    
    public String getComment() {
        return comment;
    }
    
    /**
     * 根据代码获取枚举
     *
     * @param code 源代码
     * @return 对应的枚举值，未找到返回null
     */
    public static CreationSourceEnum fromCode(String code) {
        for (CreationSourceEnum source : values()) {
            if (source.getCode().equals(code)) {
                return source;
            }
        }
        return null;
    }
    
    /**
     * 判断代码是否有效
     *
     * @param code 源代码
     * @return 是否有效
     */
    public static boolean isValidCode(String code) {
        return fromCode(code) != null;
    }

}
